package com.loveprogrammer.server.pojo;

import com.loveprogrammer.base.constant.ConstantValue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @ClassName ServerConfig
 * @Description 服务的配置内容
 * @Author admin
 * @Date 2024/1/30 10:04
 * @Version 1.0
 */
public class ServerConfig {

    private static final Logger logger = LoggerFactory.getLogger(ServerConfig.class);

    private Integer port;
    private String channelType;

    private String protocolType;

    private static ServerConfig instance = null;

    private ServerConfig(){}

    public static ServerConfig getInstance() {
        if(instance == null) {
            instance = new ServerConfig();
            instance.init();

        }
        instance.printServerInfo();
        return instance;
    }

    private void init(){
        port = 8088;
        channelType = ConstantValue.CHANNEL_TYPE_NIO;
        protocolType = ConstantValue.PROTOCOL_TYPE_TCP;
    }

    public void printServerInfo(){
        logger.info("**************Server INFO******************");
        logger.info("protocolType  : " + protocolType);
        logger.info("port          : " + port);
        logger.info("channelType   : " + channelType);
        logger.info("**************Server INFO******************");
    }

    public Integer getPort() {
        return port;
    }

    public void setPort(Integer port) {
        this.port = port;
    }

    public String getChannelType() {
        return channelType;
    }

    public void setChannelType(String channelType) {
        this.channelType = channelType;
    }

    public String getProtocolType() {
        return protocolType;
    }

    public void setProtocolType(String protocolType) {
        this.protocolType = protocolType;
    }
}
